package cn.unknowpupil.common.core.exceptions;



import cn.unknowpupil.common.core.enums.ResultStatus;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * LionException
 * 自定义异常类
 *
 * @author Yanzheng https://github.com/micyo202
 * @date 2019/07/17
 * Copyright 2019 Yanzheng. All rights reserved.
 */
@Getter
@Slf4j
public class HealthException extends RuntimeException {

    /** 结果枚举*/
    private final ResultStatus healthEnum;
    /** 自定义异常信息*/
    private final String message;
    /** 异常码 */
    private final Integer code;




    public HealthException(String message) {
        super(message);
        this.healthEnum = ResultStatus.FAILURE;
        this.message = message;
        this.code = this.healthEnum.code();
        log.error("[HealthException]************message ;{}",message);
    }
    public HealthException(String message, Throwable e) {

        super(message);
        this.healthEnum = ResultStatus.FAILURE;
        this.message = message;
        this.code = this.healthEnum.code();
        e.printStackTrace();
        log.error("[HealthException]************message ;{}",message);
    }


    public HealthException() {
        super();
        this.healthEnum = ResultStatus.FAILURE;
        this.message = healthEnum.message();
        this.code = healthEnum.code();
    }


    public HealthException(Integer code, String message) {
        super();
        this.healthEnum = ResultStatus.FAILURE;
        this.message = message;
        this.code = code;
    }

    public HealthException(ResultStatus healthEnum) {
        super(healthEnum.message());
        this.code = healthEnum.code();
        this.message = healthEnum.message();
        this.healthEnum = healthEnum;
    }



}
